package com.pmsystem.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.pmsystem.pojo.News;
import com.pmsystem.service.NewsService;

@Controller
@RequestMapping("userNews/")
public class UserNewsController {

	
	@Autowired
	NewsService newsService;
	
	

	/**
	 * 
	 * <p>Title: showReaderNews</p>  
	 * <p>Description:用户页面的新闻列表 </p>  
	 * @author 树昌
	 * @param keyword
	 * @param startRow
	 * @param pageSize
	 * @return
	 */
	@RequestMapping(value="reader",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> showReaderNews(String keyword, Integer startRow, Integer pageSize){
		
		Map<String, Object> map = new HashMap<>();
		List<News> listnews =  newsService.showReaderNews(keyword, startRow, pageSize);
		map.put("listnews", listnews);
		int size = listnews.size();
		map.put("size", size);
		return map;
	}
	
	
	/**
	 * 
	 * <p>Title: showNewsContentbyID</p>  
	 * <p>Description:用户查看新闻内容 </p>  
	 * @author 树昌
	 * @param id
	 * @return
	 */
	@RequestMapping(value="content",method=RequestMethod.POST)
	@ResponseBody
	public Map<String, Object> showNewsContentbyID(int id){
		
		Map<String, Object> map = new HashMap<>();
		String msg = null;
		News news = newsService.showNewsByIDInRelease(id);
		map.put("news", news);
		map.put("msg", msg);
		return map;
	}
	
}
